package com.app.fenak;

import com.app.fenak.asynctasks.ForgetPasswordAsyncTask;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ForgetPasswordActivity extends Activity {

	private EditText email;
	private Button getPassword;
	private SharedPreferences sharedPreferences;
	private ProgressDialog progressDialog;

	// private Editor editor ;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.forget_password);

		email = (EditText) findViewById(R.id.email_field);
		getPassword = (Button) findViewById(R.id.get_password);
		sharedPreferences = getSharedPreferences(getString(R.string.pref_name),
				Context.MODE_PRIVATE);
		// editor = sharedPreferences.edit();
	}

	@Override
	protected void onStart() {

		super.onStart();

		final String emailString = sharedPreferences.getString(
				getString(R.string.email_pref), "");
		email.setText(emailString);

		getPassword.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				progressDialog = ProgressDialog.show(
						ForgetPasswordActivity.this, "",
						getString(R.string.forget_password_dialog));
				new ForgetPasswordAsyncTask().execute(
						ForgetPasswordActivity.this, emailString);
			}
		});

	}

	public void dismissProgressDialog() {
		if (this.progressDialog != null) {
			this.progressDialog.dismiss();
		}
	}

}
